﻿<!DOCTYPE html>
<html lang="en" xmlns:v-on="http://www.w3.org/1999/xhtml">
<head>
    <meta charset="UTF-8">
    <title>商户管理</title>
    <link rel="stylesheet" href="__CSS__/supplies/bootstrap.min.css"/>
    <link rel="stylesheet" href="__CSS__/supplies/common.css"/>
    <link rel="stylesheet" href="__JS__/supplies/ztree/css/zTreeStyle/zTreeStyle.css" type="text/css">
    <link rel="stylesheet" href="__JS__/supplies/bootstrap-table/bootstrap-table.min.css">
    <link rel="stylesheet" href="__ASSETS__/css/font-awesome.min.css"/>
    <link rel="stylesheet" href="__ASSETS__/css/cyrillic.css"/>
    <link rel="stylesheet" href="__ASSETS__/css/ace-rtl.min.css"/>
    <link rel="stylesheet" href="__ASSETS__/css/ace-skins.min.css"/>
    <style>
        body {
            height: 100% ;
            overflow: hidden;
            background: white;
        }
        .table-responsive{
            height:calc(100% - 90px)
        }
        .bootstrap-table{
            height:100%
        }
        .fixed-table-container{
            height:calc(100% - 70px) !important;
        }
        .form-title {
            height: 40px;
            text-align: right;
        }
        .checkHead table .form-value input{
            height: 34px;
            width: 200px;
        }
        .form-title1{
            height: 60px;
            width: 100px;
            text-align: right;
        }
        #user_table tr td {
            vertical-align: inherit;
        !important;
        }

        .dh_type {
            width: 100%;
            height: 40px;
        }
        .file {
            position: relative;
            display: inline-block;
            background: white;
            border: 1px solid #999;
            border-radius: 4px;
            padding: 4px 12px;
            overflow: hidden;
            color: #333;
            text-decoration: none;
            text-indent: 0;
            line-height: 20px;
            top: 7px;
        }

        .file input {
            position: absolute;
            font-size: 100px;
            right: 0;
            top: 0;
            opacity: 0;
            cursor: pointer;
        }

        .dh_type li {
            float: left;
            text-align: center;
            width: 33.3%;
            height: 40px;
            line-height: 40px;
            background-color: #f3f3f3;
            cursor: pointer;
            font-size: 16px;
        }

        .dh_type .active {
            border: 1px solid #f2f2f2;
            background-color: #438eb9;
        }

        .product_content {
            width: 100%;
            min-height: 200px;
        }

        .product_content ul {
            width: 100%;
            margin-top: 5px;
            margin-left: 5px;
        }

        .product_content li {
            float: left;
            width: 30%;
            height: 30px;
            line-height: 30px;
        }

        .business_content {
            width: 80%;
            height: 80%;
            background-color: white;
            border: 1px solid rgba(0, 0, 0, .2);
            border-radius: 6px;
            -webkit-box-shadow: 0 3px 9px rgba(0, 0, 0, .5);
            box-shadow: 0 3px 9px rgba(0, 0, 0, .5);
            position: absolute;
            top: 50%;
            left: 50%;
            margin-top: -40%;
            margin-left: -40%;
            /*z-index: 9999;*/
        }
        .post-address_content{
            width: 100%;
            height: 100%;
            background-color: white;
            border: 1px solid rgba(0, 0, 0, .2);
            border-radius: 6px;
            -webkit-box-shadow: 0 3px 9px rgba(0, 0, 0, .5);
            box-shadow: 0 3px 9px rgba(0, 0, 0, .5);
            position: absolute;
            top: 50%;
            left: 50%;
            margin-top: -50%;
            margin-left: -50%;
        }
        .get-address-btn{
            margin-left: 10px;
            width: 100px;
            height: 34px;
            border-radius: 4px;
            text-align: center;
            background-color: #438eb9;
            color: #FFF;
        }
        .business_title {
            height: 40px;
            width: 100%;
            color: #333;
            font-size: 16px;
            line-height: 40px;
            padding-left: 20px;
            border-bottom: 1px solid #e5e5e5;
        }

        .business_con {
            width: 100%;
            height: calc(100% - 92px);
            border-bottom: 1px solid #e5e5e5;
            padding-left: 15px;
            padding-top: 15px;
            overflow: auto;
        }

        .business_con ul li {
            width: 100%;
            height: 35px;
            line-height: 35px;
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
        }

        .business_footer {
            width: 100%;
            height: 50px;
            padding: 10px;
        }

        .business_footer button {
            float: right;
            margin-left: 15px;
        }

        .my_skin .layui-layer-btn a {
            border-color: #999;
        !important;
            background-color: white;
        !important;
            color: #333;
        !important;
        }

        img {
            width: 75px;
            height: 75px;
            max-width: 75px;
            _width: expression(this.width > 75 ? "37.5px" : this.width);
        }

        .delete_a {
            cursor: pointer;
        }
        .product_detail_table{
            width: 100%;
            margin-top: 10px;
        }
        .product_detail_table tr th{
            height: 30px;
            line-height: 30px;
            text-align: center;
            background: #FCF8F5;
        }
        .product_detail_table tr td{
            height: 40px;
            line-height: 40px;
            text-align: center;
        }
        .product_detail_table tr{
            border-bottom: 1px solid #999;
        }
        .form-horizontal .form-value input{
            border-radius: 0;
        }
    </style>
</head>
<body>
<div id="content">

    <!--搜索-->
    <div class="checkHead" id="checkHead" style="padding-top: 10px;height: 90px;">
        <table class="checkHead-table" style="/*position: absolute;right: 0px;*/">
            <tr>
                <td class="form-title">
                    城市：
                </td>
                <td class="form-value">
                    <input v-model="searchData.city" type="text" class="search county" readonly="readonly"
                           placeholder="请选择城市"/>&nbsp;&nbsp;&nbsp;&nbsp;
                </td>

                <td class="form-title">
                    联系电话：
                </td>
                <td class="form-value">
                    <input v-model="searchData.tel" type="text" class="search" placeholder="请输入联系电话"/>&nbsp;&nbsp;&nbsp;&nbsp;
                </td>
            </tr><tr>
                <td class="form-title">
                    店铺名称：
                </td>
                <td class="form-value">
                    <input v-model="searchData.name" type="text" class="search" placeholder="请输入店铺名称"/>&nbsp;&nbsp;&nbsp;&nbsp;
                </td>
                <td class="form-title">
                    负责人：
                </td>
                <td class="form-value">
                    <input v-model="searchData.manager" type="text" class="search" placeholder="请输入负责人"/>&nbsp;&nbsp;&nbsp;&nbsp;
                </td>
                <td>
                    <button class="btn btn-default" v-on:click="searchs()">
                        <i class="icon-refresh align-top bigger-125"></i>
                        查询
                    </button>
                    <button class="btn btn-default" v-on:click="refresh">
                        <i class="icon-reply align-top bigger-125"></i>
                        重置
                    </button>
                </td>
            </tr>
        </table>
    </div>

    <div class="modal fade" id="countyModal" tabindex="-1" role="dialog" aria-labelledby="countyModalLabel"
         aria-hidden="true" data-backdrop="static">
        <div class="modal-dialog">
            <div class="modal-content" style="width: 600px;height: 500px;">
                <div class="modal-header" style="width: 100%;height: 50px;">
                    <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span
                            aria-hidden="true">×</span></button>
                    <h4 class="modal-title" id="countyModalLabel">选择郡:</h4>
                </div>
                <div class="modal-body" style="width: 100%;height: 385px;overflow: auto;">
                    <div class="zTreeDemoBackground left" id="div_tree" style="">
                        <ul id="treeDemo" class="ztree"></ul>
                    </div>
                </div>
                <div class="modal-footer" style="width: 100%;height: 65px;">
                    <button type="button" class="btn btn-default" onclick="saveCounty();" data-dismiss="modal">保存
                    </button>
                    <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                </div>
            </div>
        </div>
    </div>

    <!--店铺详情-->
    <div class="modal fade" id="detailModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel"
         aria-hidden="true" data-backdrop="static">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span
                            aria-hidden="true">×</span></button>
                    <h4 class="modal-title" id="exampleModalLabel">店铺详情</h4>
                </div>
                <div class="modal-body">
                    <form class="form-horizontal" role="form">
                        <table>
                            <tr>
                                <!--<td class="form-title1">-->
                                    <!--店铺logo：-->
                                <!--</td>-->
                                <!--<td class="form-value">-->
                                    <!--<img :src="src + formData.logo">-->
                                <!--</td>-->
                                <!--<td class="form-value">-->
                                    <!--<img class="editImg" :src="src + json_data.image">-->
                                    <!--<a href="javascript:;" class="file">选择文件-->
                                        <!--<form enctype="multipart/form-data">-->
                                            <!--<input type="file" @change="saveImg" name="image" style="">-->
                                        <!--</form>-->
                                    <!--</a>-->
                                <!--</td>-->
                                <td class="form-title">
                                    店铺logo：
                                </td>
                                <td class="form-value">
                                    <img class="editImg" :src="src + formData.image">
                                    <a href="javascript:;" class="file">选择文件
                                        <form enctype="multipart/form-data">
                                            <input type="file" @change="saveImg" name="image" style="">
                                        </form>
                                    </a>
                                </td>
                            </tr>
                            <tr>
                                <td class="form-title1">
                                    主营业务：
                                </td>
                                <td class="form-value">
                                    <input v-model="formData.business" type="text" class="search business_input form-control"/>
                                </td>

                                <td class="form-title1">
                                    店铺名称：
                                </td>
                                <td class="form-value">
                                    <input v-model="formData.name"  type="text" class="search form-control"/>
                                </td>
                            </tr>
                            <tr>
                                <td class="form-title1">
                                    邮编：
                                </td>
                                <td class="form-value">
                                    <input v-model="formData.post_code" name="post_code" type="text" class="search form-control"/>
                                </td>
                                <!--<td class="form-value">-->
                                    <!--<input type="button" class="get-address-btn" v-on:click="getAddrInfo" value="获取地址">-->
                                <!--</td>-->
                                <td class="form-title1">
                                    店铺电话：
                                </td>
                                <td class="form-value">
                                    <input v-model="formData.tel" name="tel" type="text"
                                           class="search form-control"/>
                                </td>
                            </tr>
                            <tr>
                                <td class="form-title1">
                                    店铺地址：
                                </td>
                                <td class="form-value">
                                    <input v-model="formData.address"  style="position: absolute;width: 457px;top: 223px;" name="address" type="text" readonly class="search form-control"/>
                                </td>
                            </tr>
                            <tr>
                                <!--<td class="form-title1">-->
                                    <!--店铺地址：-->
                                <!--</td>-->
                                <!--<td class="form-value">-->
                                    <!--<input v-model="formData.address"  name="address" type="text" readonly class="search form-control"/>-->
                                <!--</td>-->
                                <td class="form-title1">
                                    优惠信息：
                                </td>
                                <td class="form-value">
                                    <input v-model="formData.discount" type="text" readonly class="search form-control"/>
                                </td>
                                <td class="form-title1">
                                    公司名称：
                                </td>
                                <td class="form-value">
                                    <input v-model="formData.company"  name="company" type="text" class="search form-control"/>
                                </td>
                            </tr>
                            <tr>
                                <td class="form-title1">
                                    负责人：
                                </td>
                                <td class="form-value">
                                    <input v-model="formData.manager" name="account" type="text"
                                           class="search form-control"/>
                                </td>
                                <td class="form-title1">
                                    联系电话：
                                </td>
                                <td class="form-value">
                                    <input v-model="formData.manager_tel" name="manager_tel" type="text"
                                           class="search form-control"/>
                                </td>
                            </tr>
                            <tr>

                                <td class="form-title1">
                                    账号：
                                </td>
                                <td class="form-value">
                                    <input v-model="formData.account" name="account" readonly   type="text"
                                           class="search form-control"/>
                                </td>
                                <td class="form-title1">
                                    密码：
                                </td>
                                <td class="form-value">
                                    <input v-model="formData.password" name="password"
                                           type="password" class="search form-control"/>
                                </td>
                            </tr>
                        </table>
                    </form>
                    <div class="business_content" style="display: none;">
                        <div class="business_title">
                            选择主营业务
                        </div>
                        <div class="business_con">
                            <ul id="bus">
                            </ul>
                        </div>
                        <div class="business_footer">
                            <button type="button" class="btn btn-default" v-on:click="selectBusiness()">确定</button>
                            <button type="button" class="btn btn-default" v-on:click="business">关闭</button>
                        </div>
                    </div>
                    <div class="post-address_content" style="display: none">
                        <div class="business_title">
                            选择地址
                        </div>
                        <div class="business_con">
                            <ul id="postAddress">
                                <li  v-for="(value,key) in addr_info">
                                        <input type="radio" name="address" :value="key" >{{value.postal_code}},{{value.addr}}
                                </li>
                            </ul>
                        </div>
                        <div class="business_footer">
                            <button type="button" class="btn btn-default" v-on:click="closePostCode">关闭</button>
                            <button type="button" class="btn btn-default" v-on:click="selectAddr">确定</button>
                        </div>
                    </div>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal" v-on:click="saveSupplierInfo()">
                        保存
                    </button>
                    <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                </div>
            </div>
        </div>
    </div>
    <!--商品详情-->
    <div class="modal fade" id="productModal" tabindex="-1" role="dialog" aria-labelledby="productModalLabel"
         aria-hidden="true" data-backdrop="static">
        <div class="modal-dialog" style="">
            <div class="modal-content" style="width: 600px;height: 500px;">
                <div class="modal-header" style="width: 100%;height: 50px;">
                    <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span
                            aria-hidden="true">×</span></button>
                    <h4 class="modal-title" id="productModalLabel">商品信息:</h4>
                </div>
                <div class="modal-body" style="overflow: auto; width: 100%;height: 385px;">
                    <div class="dh_type">
                        <ul id="type">
                            <li class="active product_dh" data-value="1">销售中</li>
                            <li class="product_dh" data-value="2">待上架</li>
                            <li class="product_dh" data-value="3">审核中</li>
                        </ul>
                    </div>
                    <div class="product_content">
                        <table class="product_detail_table">
                            <thead>
                            <tr>
                                <th>编号</th>
                                <th>名称</th>
                                <th>单价</th>
                            </tr>
                            </thead>
                            <tbody>
                            <tr  v-for="site in sites">
                                <td>{{ site.id }}</td>
                                <td>{{ site.name}}</td>
                                <td>{{ site.price}}</td>
                            </tr>
                            </tbody>
                        </table>
                    </div>
                </div>
                <div class="modal-footer" style="width:100%;height: 65px;">
                    <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                </div>
            </div>
        </div>
    </div>

    <!--认证信息-->
    <div class="modal fade" id="certifiedModal" tabindex="-1" role="dialog" aria-labelledby="certifiedModalLabel"
         aria-hidden="true" data-backdrop="static">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span
                            aria-hidden="true">×</span></button>
                    <h4 class="modal-title" id="certifiedModalLabel">认证信息:</h4>
                </div>
                <div class="modal-body">
                    <form class="form-horizontal" role="form">
                        <table>
                            <tr>
                                <td class="form-title1">
                                    公司名称：
                                </td>
                                <td class="form-value">
                                    <input v-model="authData.company" readonly="readonly" type="text" class="search form-control"/>
                                </td>
                                <td class="form-title1">
                                    负责人：
                                </td>
                                <td class="form-value">
                                    <input v-model="authData.manager" readonly="readonly" type="text" class="search form-control"/>
                                </td>
                            </tr>
                            <tr>
                                <td class="form-title1">
                                    邮编：
                                </td>
                                <td class="form-value">
                                    <input v-model="authData.post_code" readonly="readonly" type="text" class="search form-control"/>
                                </td>
                                <td class="form-title1">
                                    地址：
                                </td>
                                <td class="form-value">
                                    <input v-model="authData.address" type="text" readonly="readonly" class="search form-control"/>
                                </td>
                            </tr>
                            <tr>
                                <td class="form-title1">
                                    联系电话：
                                </td>
                                <td class="form-value">
                                    <input v-model="authData.manager_tel" readonly="readonly" type="text"
                                           class="search form-control"/>
                                </td>
                                <td class="form-title1">
                                    公司注册号码：
                                </td>
                                <td class="form-value">
                                    <input v-model="authData.company_code" type="text" readonly="readonly"
                                           class="search form-control"/>
                                </td>
                            </tr>
                        </table>
                    </form>
                </div>
                <div class="modal-footer">
                    <!--<button type="button" class="btn btn-default" data-dismiss="modal">保存</button>-->
                    <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                </div>
            </div>
        </div>
    </div>
</div>
<div class="table-responsive" style="background:white;margin-top: 0px;">
    <table class="table" id="user_table"></table>
</div>

<script rel="script" src="__JS__/supplies/jquery.min.js"></script>
<script rel="script" src="__JS__/supplies/bootstrap.min.js"></script>
<script rel="script" src="__JS__/supplies/bootstrap-table/bootstrap-table.min.js"></script>
<script rel="script" src="__JS__/supplies/bootstrap-table/locale/bootstrap-table-zh-CN.min.js"></script>
<script rel="script" src="__JS__/supplies/vue.min.js"></script>
<script rel="script" src="__JS__/supplies/vue-validator.min.js"></script>
<script rel="script" src="__JS__/supplies/common.js"></script>
<script rel="script" src="__JS__/supplies/ztree/jquery.ztree.all.min.js"></script>
<script rel="script" src="__JS__/supplies/layer/layer.js"></script>
<script rel="script" src="__JS__/vue-resource.js"></script>
<script>
    var searchData = {};
    var setting = {
        view: {
            selectedMulti: false
        },
        async: {
            enable: true,
            url: "{:url('apishop/Index/getAreaTree')}",
            autoParam: ["name", "nameEn"],
            otherParam: {"otherParam": "zTreeAsyncTest"},
            dataFilter: filter
        },
        callback: {
            beforeClick: beforeClick,
            beforeAsync: beforeAsync,
            onAsyncError: onAsyncError,
            onAsyncSuccess: onAsyncSuccess
        }
    };

    function filter(treeId, parentNode, childNodes) {
        if (!childNodes) return null;
        for (var i = 0, l = childNodes.length; i < l; i++) {
            childNodes[i].name = childNodes[i].name.replace(/\.n/g, '.');
        }
        return childNodes;
    }

    function beforeClick(treeId, treeNode) {
        if (!treeNode.isParent) {
            {
            }
        } else {
            return true;
        }
    }

    var log, className = "dark";

    function beforeAsync(treeId, treeNode) {

        className = (className === "dark" ? "" : "dark");
        showLog("[ " + getTime() + " beforeAsync ]&nbsp;&nbsp;&nbsp;&nbsp;" + ((!!treeNode && !!treeNode.name) ? treeNode.name : "root"));
        return true;
    }

    function onAsyncError(event, treeId, treeNode, XMLHttpRequest, textStatus, errorThrown) {
        showLog("[ " + getTime() + " onAsyncError ]&nbsp;&nbsp;&nbsp;&nbsp;" + ((!!treeNode && !!treeNode.name) ? treeNode.name : "root"));
    }

    function onAsyncSuccess(event, treeId, treeNode, msg) {
        showLog("[ " + getTime() + " onAsyncSuccess ]&nbsp;&nbsp;&nbsp;&nbsp;" + ((!!treeNode && !!treeNode.name) ? treeNode.name : "root"));
    }

    function showLog(str) {
        if (!log) log = $("#log");
        log.append("<li class='" + className + "'>" + str + "</li>");
        if (log.children("li").length > 8) {
            log.get(0).removeChild(log.children("li")[0]);
        }
    }

    function getTime() {
        var now = new Date(),
            h = now.getHours(),
            m = now.getMinutes(),
            s = now.getSeconds(),
            ms = now.getMilliseconds();
        return (h + ":" + m + ":" + s + " " + ms);
    }

    function refreshNode(e) {
        var zTree = $.fn.zTree.getZTreeObj("treeDemo"),
            type = e.data.type,
            silent = e.data.silent,
            nodes = zTree.getSelectedNodes();
        if (nodes.length == 0) {
            alert("请先选择一个父节点");
        }
        for (var i = 0, l = nodes.length; i < l; i++) {
            zTree.reAsyncChildNodes(nodes[i], type, silent);
            if (!silent) zTree.selectNode(nodes[i]);
        }
    }

    $(document).ready(function () {

        $('img').error(function(){
            $(this).attr('src', "__IMG__/supplies/sh.png");
        });

        $('input[name=post_code]').change(function () {
           vm.getAddrInfo();
        });
        $('#type li').bind('click', function () {
            var type = $(this).attr('data-value');
            vm.detailProducts(vm.id, type);
        });

        $.fn.zTree.init($("#treeDemo"), setting);

        $(".county").on("click", function () {
            $('#countyModal').modal({
                keyboard: true
            })
        })

        $(".product_dh").on("click", function () {
            $(".product_dh").removeClass("active");
            $(this).addClass("active");
        })
        $(".business_input").on("click", function () {
            $.ajax({
                url: '{:url("admin/Product/getBusinessInfo")}',
                type: "POST",
                data: {},
                success: function (data) {
                    if (data.status == 200) {
                        var html = '';
                        for (item in data.data) {
                            var status = getCheckStatus(data.data[item].name);
                            if (status == true) {
                                html += '<li><label><input checked type="checkbox" flog="' + data.data[item].name + '" value="' + data.data[item].id + '" />' + data.data[item].name + '</label></li>';
                            }
                            else {
                                html += '<li><label><input type="checkbox" flog="' + data.data[item].name + '" value="' + data.data[item].id + '"/>' + data.data[item].name + '</label></li>';
                            }
                        }
                        $('#bus').html(html);
                    }
                }
            });
            $(".business_content").css("display", "block");
        })

        $('#productModal').on('hidden.bs.modal', function () {
            $(".product_dh").removeClass("active");
            $(".product_dh").eq(0).addClass("active");
        })
    });
    var tableheight = document.documentElement.clientHeight - 96;

    function getCheckStatus(item) {
        var status = false;
        for (key in vm.sel_business) {
            if (item == vm.sel_business[key]) {
                status = true;
            }
        }
        return status;
    }

    $('#user_table').bootstrapTableEx({
        height: tableheight,
        url: '{:url("admin/Supplier/supplierList")}',
        columns: [
            {
                checkbox: true
            }, {
                field: 'admin_name2',
                align: 'center',
                title: '城市',
                width: 180
            }, {
                field: 'image',
                align: 'center',
                title: '店铺logo',
                width: 200,
                formatter: function (val, row, index) {
                    if(val)
                    {
                        return "<img src='"+oss_url + val + "'>"
                    }
                    else
                    {
                        return "<img src='__IMG__/supplies/sh.png'>"
                    }
                }
            }, {
                field: 'name',
                align: 'center',
                title: '店铺名称'
            }, {
                field: 'company',
                align: 'center',
                title: '公司名称'
            }, {
                field: 'manager',
                align: 'center',
                title: '负责人'
            }, {
                field: 'manager_tel',
                align: 'center',
                title: '联系电话'
            },{
                title: '操作',
                align: 'center',
                width: 400,
                formatter: operateFormatter
            }
        ],
        queryParams: function (params) {
            var param = {
                search: searchData,
                pageSize: params.pageSize,
                pageNumber: params.pageNumber
            };
            return param;
        },
        responseHandler: function (res) {
            if (res.data) {
                return {
                    rows: res.data,
                    total: res.count
                };
            }
        }
    });

    // 详情按钮
    function operateFormatter(val, row, index) {

        var divStr = "<div class='form-inline'>"
        if (row.is_open == 1) {
            var detailStr = "<a href='javascript:void(0);' class='detail_a' onclick='detailSupply(1," + row.id + ")'>查看详情</a>&nbsp;&nbsp;"
            detailStr += "<a href='javascript:void(0);' class='detail_a' onclick='detailProduct(1," + row.id + ")'>查看商品</a>&nbsp;&nbsp;"
            detailStr += "<a href='javascript:void(0);' class='detail_a' onclick='detailCertified(1," + row.id + ")'>认证信息</a>&nbsp;&nbsp;"
            detailStr += "<a href='javascript:void(0);' class='detail_a' onclick='colseSupply(1," + row.id + ")'>关闭店铺</a>&nbsp;&nbsp;"
        }
        else {
            var detailStr = "<a href='javascript:void(0);' class='detail_a' onclick='detailSupply(1," + row.id + ")'>查看详情</a>&nbsp;&nbsp;"
            detailStr += "<a href='javascript:void(0);' class='detail_a' onclick='detailProduct(1," + row.id + ")'>查看商品</a>&nbsp;&nbsp;"
            detailStr += "<a href='javascript:void(0);' class='detail_a' onclick='detailCertified(1," + row.id + ")'>认证信息</a>&nbsp;&nbsp;"
            detailStr += "<a href='javascript:void(0);' class='detail_a' onclick='openSupplier(1," + row.id + ")'>开启店铺</a>&nbsp;&nbsp;"
        }
        divStr += detailStr;
        divStr += "</div>";
        return divStr;
    }

    function detailSupply(index, id) {
        vm.supplierDetail(index, id);

    }

    function detailProduct(index, id) {
        vm.detailProducts(id, 1);

    }

    function detailCertified(index, id) {
        vm.supplierAuthInfo(index, id);

    }

    function colseSupply(index, id) {
        vm.closeSupplier(index, id, 'close');
    }

    function btn_search() {
        $('#detailModal').modal({
            keyboard: true
        })
    }

    function saveCounty() {
        var zTree = $.fn.zTree.getZTreeObj("treeDemo");
        var nodes = zTree.getSelectedNodes();
        //console.log(nodes);
        if (nodes.length == 0) {
            alert("请选择郡");
            return false;
        }
        $(".county").val(nodes[0].name);
    }

    function openSupplier(index, id) {
        vm.closeSupplier(index, id, 'open');
    }

    vm = new Vue({
        el: "#content",
        data: {
            src: oss_url,
            searchData: {
//                key_word:'',
            },
            formData: {
                name: '',
                logo: '',
                post_code: '',
                address: '',
                company: '',
                manager: '',
                manager_tel: '',
                password: '',
                account: '',
                business: '',
                business_ids: '',
            },
            authData: {
                company: '',
                manager: '',
                post_code: '',
                address: '',
                company_code: '',
                manager_tel: '',
            },
            sites: [{
                name: '暂无数据',
            }],
            id: '',
            sel_business: [],
            business_data: {},
            addr_info : {},
        },
        methods: {
            searchs: function (index) {
                searchData = this.searchData;
                var city = $('.county').val();
                if (city) {
                    searchData.city = $('.county').val();
                }
                if (index == 1) {
                    $("#user_table").bootstrapTable('refresh');
                } else {
                    $("#user_table").bootstrapTable('refresh');
                }
            },
            saveImg: function (e) {
                var fData = new FormData();
                fData.append('image', e.target.files[0]);
                fData.append('id', this.id);
                $.ajax({
                    url: "{:url('admin/Supplier/uploadImg')}",
                    type: 'POST',
                    dataType: 'json',
                    cache: false,
                    data: fData,
                    processData: false,
                    contentType: false,
                    success: function (res) {
                        vm.formData.image = res.data.image;
                    }
                });
            },
            detailProducts: function (id, types) {
                vm.sites = [{
                    name: '暂无数据',
                }];
                vm.id = id;
                $.ajax({
                    url: '{:url("apiShop/Product/getProductList")}',
                    type: "POST",
                    data: {'supplier_id': vm.id, 'types': types},
                    success: function (data) {
                        if (data.status == 200) {
                            vm.sites = data.data;
                        }
                    }
                });
                $("#productModal").modal({
                    keyboard: true
                });
            },
            supplierAuthInfo: function (index, id) {
                $("#certifiedModal").modal({
                    keyboard: true
                });
                $.ajax({
                    url: '{:url("admin/Supplier/supplierDetail")}',
                    type: "POST",
                    data: {'id': id},
                    success: function (data) {
                        vm.authData = data.data;
                    }
                })
            },
            supplierDetail: function (index, id) {
                vm.formData = {};
                $("#detailModal").modal({
                    keyboard: true
                });
                $.ajax({
                    url: "{:url('admin/Supplier/supplierDetail')}",
                    type: 'POST',
                    data: {'id': id},
                    success: function (data) {
                        if (data.status == 200) {
                            vm.formData = data.data;
                            vm.formData.logo = data.data.image;
                            var str = '';
                            for (var i = 0; i < data.data.business.length; i++) {
                                vm.sel_business.push(data.data.business[i].name);
                                if (i < data.data.business.length - 1) {
                                    str += data.data.business[i].name + '、';
                                }
                                else {
                                    str += data.data.business[i].name;
                                }
                            }
                            vm.formData.business = str;
                        }
                    }
                })
            },
            closeSupplier: function (index, id, type) {
                $.ajax({
                    url: '{:url("admin/Supplier/closeSupplier")}',
                    type: "POST",
                    data: {'id': id, 'type': type},
                    success: function (data) {
                        layer.confirm(data.msg, {
                            time: 20000, //20s后自动关闭
                            btn: ['关闭']
                        }, function () {
                            layer.closeAll('dialog');
                            $("#user_table").bootstrapTable('refresh');
                        });
                    }
                })
//                    });
            },
            business: function () {
                $(".business_content").css("display", "none");
            },
            selectBusiness: function () {
                vm.formData.business = '';
                vm.formData.business_ids = '';
                vm.sel_business = [];
                var i = 0;
                $('#bus :checked').each(function () {
                    vm.sel_business.push($(this).attr('flog'));
                    if (i < $('#bus :checked').length - 1) {
                        vm.formData.business += $(this).attr('flog') + '、';
                        vm.formData.business_ids += $(this).val() + ',';
                    }
                    else {
                        vm.formData.business += $(this).attr('flog');
                        vm.formData.business_ids += $(this).val();
                    }
                    ++i;
                });
                $(".business_content").css("display", "none");
            },
            saveSupplierInfo: function () {
                $.ajax({
                    url: '{:url("admin/Supplier/updateSupplierInfo")}',
                    type: "POST",
                    data: vm.formData,
                    success: function (data) {
                        layer.confirm(data.msg, {
                            time: 20000, //20s后自动关闭
                            btn: ['关闭']
                        }, function () {
                            layer.closeAll('dialog');
                            $("#user_table").bootstrapTable('refresh');
                        });
                    }
                })
            },
            refresh : function () {
                this.searchData = {};
            },
            getAddrInfo : function () {
                var url = "{:url('userweb/Login/zipCode')}";
                this.$http.post(url,{
                    postcode : this.formData.post_code,
                }).then(function (data) {
                    vm.addr_info = data.body.data.list;
                    $('.post-address_content').css('display','block')
                })
            },
            closePostCode : function () {
                $('.post-address_content').css('display','none')
            },
            selectAddr : function () {
                var a = $('input[name=address]:checked').val()
                if(a)
                {
                    this.formData.post_code = this.addr_info[a].postal_code;
                    this.formData.address = this.addr_info[a].addr;
                    $('.post-address_content').css('display','none')
                }
                else
                {
                    alert('请选择地址!')
                }
            }
        },
    });
</script>
</body>
</html>